package cn.afactory.tygz.ui.base.utils;

import android.app.Activity;
import android.view.View;

/**
 * Created by Kenneth on 15/9/9.
 */
public class ViewUtils {
    public static <T> T findView(Activity activity, int resId) {
        T v = null;
        try {
            v = (T) activity.findViewById(resId);
        } catch (Exception e) {
            throw new NullPointerException("Not find the view by id:" + resId);
        }
        return v;
    }

    public static <T> T findView(View view, int resId) {

        T v = null;
        try {
            v = (T) view.findViewById(resId);
        } catch (Exception e) {
            throw new NullPointerException("Not find the view by id:" + resId);
        }
        return v;
    }
}
